package edu.jd.block_chain.forum.inChat.dao;

import edu.jd.block_chain.forum.inChat.HostChat;
import edu.jd.block_chain.forum.inChat.InChatDto;
import edu.jd.block_chain.forum.inChat.SubChat;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @descriptions:
 * @data: 2021/11/26 16:38
 */
public interface InChatDao {
    List<HostChat> getHostChatList(Integer p_id);

    List<SubChat> getSubChatListByHostId(Integer in_c_host_id);

    @Insert("insert into inChat(in_c_host_id,u_id,p_id,in_c_text,in_c_time) values (#{in_c_host_id},#{u_id},#{p_id},#{in_c_text},#{in_c_time})")
    void addHostChat(InChatDto dto);

    @Select("select max(in_c_host_id)+1 from inChat where p_id=#{p_id}")
    Integer getHostId(Integer p_id);

    @Select("select max(in_c_sub_id)+1 from inChat where p_id=#{p_id} and in_c_host_id=#{in_c_host_id}")
    Integer getSubId(Integer p_id, Integer in_c_host_id);

    @Insert("insert into inChat(in_c_host_id,in_c_sub_id,u_id,p_id,in_c_text,in_c_time) values (#{in_c_host_id},#{in_c_sub_id},#{u_id},#{p_id},#{in_c_text},#{in_c_time})")
    void addSubChat(InChatDto dto);
}
